/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 * Description: 性能评估器相关源文件
 * Author: qingjicheng
 * Create: 2022-8-1
 */

#include "connected_graph_builder.h"
#include "evaluator_log_def.h"

namespace HcclEvaluator {
ConnectedGraphBuilder::ConnectedGraphBuilder()
{
}

ConnectedGraphBuilder::~ConnectedGraphBuilder()
{
}

HcclResult ConnectedGraphBuilder::BuildConnectedGraph(HcclTopology* topo, ConnectedGraph &graph)
{
    std::vector<AdjacencyMatrix<>> matrixes;
    TimePoint start = TimeNow();
    EVALUATOR_CHK_RET(splitter_.Split(topo, matrixes));
    EVALUATOR_INFO("split duration = %lld us\n", DurationUs(TimeNow() - start));

    for (u32 i = 0; i < matrixes.size(); i++) {
        EVALUATOR_CHK_RET(graph.SetSubgraphAdjaMutrix(std::move(matrixes[i]), i));
    }

    EVALUATOR_CHK_RET(graph.ParseAllSubgraphs());

    return HCCL_SUCCESS;
}
} // namespace HcclEvaluator